﻿// (c)2010 David Schwarz (david.schwarz@live.com)
// This file is licensed under GNU GPL v2 license, see more at http://www.gnu.org/licenses/gpl-2.0.html
namespace Z2.Core
{

	#region Using

	using System;
	using System.Xml;

	#endregion

	/// <summary>
	/// Pomocná třída pro definici objektu/políčka
	/// </summary>
	public class FieldDefinition
	{

		#region Members

		private bool m_solid;
		private string m_graphics;
		private int m_framesX;
		private int m_framesY;
		private WorldFieldDraw m_draw;

		#endregion

		#region Constructor

		/// <summary>
		/// Konstruktor
		/// </summary>
		/// <param name="node">Xml uzel obsahující hodnoty definice</param>
		public FieldDefinition(XmlNode node)
		{
			if (node.Attributes["Solid"] != null)
				this.m_solid = Convert.ToBoolean(node.Attributes["Solid"].Value);
			else this.m_solid = true;

			if (node.Attributes["FramesX"] != null)
				this.m_framesX = Convert.ToInt32(node.Attributes["FramesX"].Value);
			else this.m_framesX = 1;

			if (node.Attributes["FramesY"] != null)
				this.m_framesY = Convert.ToInt32(node.Attributes["FramesY"].Value);
			else this.m_framesY = 1;

			if (node.Attributes["Draw"] != null)
				this.m_draw = (WorldFieldDraw) Convert.ToInt32(node.Attributes["Draw"].Value);
			else this.m_draw = 0;

			this.m_graphics = node.Attributes["Graphics"].Value.Trim();

		}

		#endregion

		#region Properties

		/// <summary>
		/// Vrací pozici vykreslení
		/// </summary>
		public WorldFieldDraw Draw
		{
			get
			{
				return this.m_draw;
			}
		}

		/// <summary>
		/// Počet snímků v ose Y
		/// </summary>
		public int FramesY
		{
			get
			{
				return this.m_framesY;
			}
		}

		/// <summary>
		/// Počet snímků v ose X
		/// </summary>
		public int FramesX
		{
			get
			{
				return this.m_framesX;
			}
		}

		/// <summary>
		/// Název assesmentu
		/// </summary>
		public string Graphics
		{
			get
			{
				return this.m_graphics;
			}
		}

		/// <summary>
		/// Vrací true pokud je neprůchozí
		/// </summary>
		public bool Solid
		{
			get
			{
				return this.m_solid;
			}
		}

		#endregion

	}
}
